<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>02methods方法实现</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>{{title}}</h1>
    姓：<input type="text" v-model="firstName">
    <br>
    名：<input type="text" v-model="lastName">
    <br>
    全名：<span>{{fullName()}}</span>
  </div>
  <script>
    new Vue({
      el: '#app',
      data() {
        return {
          title: 'methods方法实现',
          firstName: 'zhang',
          lastName: 'san'
        }
      },
      methods: {
        fullName() {
          return this.firstName.slice(0, 3) + '-' + this.lastName
        }
      }
    })
  </script>
</body>
</html>